program Task2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a, b, d, e, c: integer;
  mass: array of integer;
  fin, fout: textFile;

begin
  assignFile(fin, 'input.txt');
  reset(fin);
  assignFile(fout,'output.txt');
  rewrite(fout);
  readln(fin, c);
  setlength(mass, c);
  for a:=0 to c-1 do
    read(fin,mass[a]);
  for b:=0 to c-2 do
  begin
    d:=b;                                      
    for a:=b+1 to c-1 do
    begin
      if (mass[a]<mass[d]) then
      d:=a;
    end;
    e:=mass[b];
    mass[b]:=mass[d];
    mass[d]:=e;
  end;
  write(fout, mass[0]+mass[c-1]);
  close(fin);
  close(fout);
end.
